// @Desc: 定时任务
// @CreateTime: 2020/10/22
package corntask

import (
	// "github.com/robfig/cron/v3"
	"github.com/robfig/cron/v3"
	"mycrm.com/controller/visit"
	mlog "mycrm.com/mylog"
)

// 初始化定时任务
func InitCronTask() error {
	cronObj := cron.New()
	// 每小时统计一次
	_, err := cronObj.AddFunc("0 23 * * ?", visit.StatisticsVisitByDay)
	if err != nil {
		mlog.Log.Error("cronObj.AddFunc is failed, err: ", err)
		return err
	}
	cronObj.Start()
	return nil
}
